import java.util.Timer;
import java.util.TimerTask;

//TIP To <b>Run</b> code, press <shortcut actionId="Run"/> or
// click the <icon src="AllIcons.Actions.Execute"/> icon in the gutter.
public class Main {
    public static void main(String[] args) throws InterruptedException {
        Timer timer = new Timer();
        timer.schedule(new TimerTask() {
            @Override
            public void run() {
                System.out.println(2000);
                System.out.println(Thread.currentThread().getName());
            }
        },2000);

        timer.schedule(new TimerTask() {
            @Override
            public void run() {
                System.out.println(3000);
                System.out.println(Thread.currentThread().getName());
            }
        },3000);
        System.out.println(Thread.currentThread().getName());
        Thread.sleep(3500);
        //timer.cancel();
        //一个Timer那只有一个当前Timer线程，无论schedule几次都是，故关当前的timer即可关了所有的计时器

    }

}